// pages/dishesDetail/dishesDetai.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var _dishesid = options.dishesid;
    var that = this;
    wx.request({
      url: app.globalData.ip + '/api/dishes/' + _dishesid,
      method: "GET",
      success: e => {
        console.log(e);
        var _ifRecommend = false;
        if (e.data.data.state == 1) {
          _ifRecommend = true;
        }
        that.setData({
          dishes: e.data.data,
          ifRecommend: _ifRecommend
        })
      }
    })
  },
  addToCart: function() {
    var that = this;
    // console.log(that.data.dishes);
    wx.switchTab({
      url: '../menu/menu?dishesid=' + that.data.dishes.id,
    })
  }
})